home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / faq / wdj0597.zip / TOMLINSN.ZIP / TEST.C < prev   
C/C++ Source or Header  |  1997-03-04  |  1KB  |  53 lines

  1. #if 0
  2. rem ** build.bat
  3. rem ** uncomment the appropriate lines for your compiler **
  4. rem **
  5. rem build with Borland C++
  6. rem bcc32 -w -DSTRICT test.c security.c
  7. rem **
  8. rem build with Visual C++
  9. rem cl /W3 /DSTRICT test.c security.c advapi32.lib
  10. #endif
  11.  
  12.  
  13. #include <windows.h>
  14. #include <stdio.h>
  15. #include "security.h"
  16.  
  17. void main(void)
  18. {
  19.     SYSTEMTIME st;
  20.     DWORD status;
  21.     HANDLE token;
  22.  
  23.     if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&token)) {
  24.         DumpAccessToken(token);
  25.         CloseHandle(token);
  26.     }
  27.  
  28.     if (IsUserInGroup("Everyone")) {
  29.         printf("Current user is member of Everyone group\n");
  30.     }
  31.     if (IsUserInGroup("Administrators")) {
  32.         printf("Current user is member of Administrators group\n");
  33.     }
  34.     if (IsUserInGroup("Guests")) {
  35.         printf("Current user is member of Guests group\n");
  36.     }
  37.  
  38.     GetSystemTime(&st);
  39.     status = EnablePrivilege(SE_SYSTEMTIME_NAME, TRUE);
  40.     if (status == ERROR_SUCCESS) {
  41.         st.wDay++;
  42.         SetSystemTime(&st);
  43.     } else {
  44.         if (status == ERROR_NOT_ALL_ASSIGNED) {
  45.             printf("Couldn't enable privilege; the privilege probably doesn't\n");
  46.             printf("exist in this access token.\n");
  47.         } else {
  48.             printf("Error %d\n", status);
  49.         }
  50.     } 
  51.  
  52. } // main
  53.